Skip to content

Implement initial PyAutoBrain Build Agent - #3

Merged
Jammy2211 merged 2 commits into
mainfrom
claude/build-agent-implementation-va40mp
Jun 29, 2026
Merged

Implement initial PyAutoBrain Build Agent#3
Jammy2211 merged 2 commits into
mainfrom
claude/build-agent-implementation-va40mp

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Summary

Adds the Build Agent — the second canonical PyAutoBrain reasoning agent and the reference example of the Brain coordinating multiple organs. It is the executive/orchestration layer for execution work: it owns the build workflow but delegates the building to PyAutoBuild and the health decision to the Health Agent. It reasons; PyAutoBuild executes.

Implements the task in PyAutoMind/feature/pyautobrain/build.md.

Architecture

The centrepiece: Brain agents consult one another. The Build Agent does not query PyAutoHeart directly — it consults the sibling Health Agent, and only the Health Agent talks to the Heart organ.

Mind  →  Build Agent  →  Health Agent  →  Heart  →  GREEN/YELLOW/RED
                      →  Build Agent  →  PyAutoBuild (execute)

This generalises to a future society of agents (Feature Agent asks Health Agent about refactor readiness; Release Agent asks Build Agent to package).

Release as a mode, with a clean seam

Release is in scope today (PyAutoBuild owns release/build/deploy execution) but isolated as a mode, so release-specific reasoning never bleeds into generic build execution and can split into a dedicated Release Agent later — one agent now, clean seam for two later.

Mode Default action Gate policy Routes to (PyAutoBuild)
build run_all lenient — GREEN/YELLOW proceed, RED aborts generate, run, run_python, run_all, script_matrix, aggregate_results, slow_skip_check, repro_command, bump_colab_urls
deploy generate cautious — GREEN proceeds, YELLOW needs --force, RED aborts generate, bump_colab_urls
release pre_build strict — refreshes health first; GREEN proceeds, YELLOW needs --force, RED aborts pre_build, tag_and_merge, generate_release_notes, create_analysis_issue, aggregate_results

An unknown verdict collapses to YELLOW — never silently GREEN.

Files

  • agents/build/build.sh — deterministic entrypoint. Parses mode/action, consults the Health Agent, applies the per-mode gate, emits a structured BuildDecision (JSON), then delegates to the matching autobuild capability. --dry-run plans without executing.
  • agents/build/AGENTS.md — concise agent doc (<200 lines) incl. the BuildDecision schema and mode/gate table.
  • agents/build/BUILD_CAPABILITIES.md — audit of every PyAutoBuild execution capability the agent calls, plus the boundary finding: the health-shim commands (verify_install, url_check, watch/status/tick/fix) belong to Heart and are refused here, reached via pyauto-brain health.
  • agents/_common.shconsult_health_agent_verdict helper (agent-to-agent consult, pipefail-safe).
  • bin/pyauto-brain — register the build agent (listed first).
  • README.md, AGENTS.md — document the organism, multi-organ coordination, the society-of-agents pattern, and the future Release Agent split.

BuildDecision

{
  "agent": "build",
  "mode": "build|deploy|release",
  "requested_action": "<PyAutoBuild capability>",
  "health_status": "green|yellow|red|unknown",
  "decision": "proceed|proceed-with-caution|abort",
  "execution_plan": ["autobuild <action> <args>"],
  "execution_summary": "<one line>",
  "warnings": ["..."],
  "blockers": ["..."],
  "follow_up_recommendations": ["..."],
  "dry_run": false
}

Validation

Exercised end-to-end with stubbed Heart/autobuild:

  • dispatcher listing, help, help build, build --help, pyauto-agent back-compat shim
  • every gate path (green/yellow/red/unknown) across all three modes
  • --dry-run (plan only, no execution)
  • health-shim rejection (build tick → pointed at pyauto-brain health)
  • invalid mode / invalid action for mode
  • full GREEN happy path delegating to a stubbed autobuild with forwarded args
  • RED correctly aborts (exit 3, autobuild never runs)
  • all .md files under the 200-line guidance; bash syntax checks pass

No existing functionality regresses — every PyAutoBuild execution capability remains usable through the Build Agent.

🤖 Generated with Claude Code


Generated by Claude Code

The Build Agent is the executive/orchestration layer for execution work. It
does not build software itself — PyAutoBuild does. It decides whether, what, and
which PyAutoBuild capability to invoke, then delegates. This makes it the
canonical example of the Brain coordinating multiple organs.

Architectural centrepiece: Brain agents consult one another. The Build Agent
does not query PyAutoHeart directly — it consults the sibling Health Agent, and
only the Health Agent talks to the Heart organ:

  Mind -> Build Agent -> Health Agent -> Heart -> GREEN/YELLOW/RED
                      -> Build Agent -> PyAutoBuild (execute)

Release is kept as a *mode* (build/deploy/release) with a clean seam to a future
Release Agent: release reasoning is isolated, consults health more strictly
(refreshes the verdict first), and never bleeds into generic build execution.

- agents/build/build.sh: deterministic entrypoint. Parses mode/action, consults
  the Health Agent, applies a per-mode gate (build lenient, deploy/release need
  --force on yellow, red always aborts, unknown collapses to yellow), emits a
  structured BuildDecision (JSON), then delegates to the matching autobuild
  capability. --dry-run plans without executing.
- agents/build/AGENTS.md: concise agent doc (<200 lines) incl. the BuildDecision
  schema and mode/gate table.
- agents/build/BUILD_CAPABILITIES.md: audit of every PyAutoBuild execution
  capability the agent calls, plus the boundary finding that the health-shim
  commands (verify_install, url_check, watch/status/tick/fix) belong to Heart
  and are refused here — reached via `pyauto-brain health`.
- agents/_common.sh: consult_health_agent_verdict helper (agent-to-agent
  consult, pipefail-safe).
- bin/pyauto-brain: register the build agent (listed first).
- README.md, AGENTS.md: document the organism, multi-organ coordination, the
  society-of-agents pattern, and the future Release Agent split.

Validated: dispatcher listing, help, all gate policies (green/yellow/red/
unknown across the three modes), health-shim rejection, invalid mode/action,
and the full green happy path delegating to a stubbed autobuild.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 29, 2026 11:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Self-review of the Build Agent surfaced one real bug:

- `--mode` as the final argument (no value) caused an infinite loop: under
  `set -uo pipefail` (no errexit), `shift 2` fails when only one positional
  remains, the loop condition stays true, and `$1` is still `--mode`, so it
  spins forever. Guard with an explicit arity check that errors (exit 5) when
  `--mode` has no value.
- Removed a leftover no-op line (`[[ ... ]] || true`) that computed and
  discarded a condition.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants